1 | n/a | from tkinter import * |
---|
2 | n/a | |
---|
3 | n/a | |
---|
4 | n/a | class Test(Frame): |
---|
5 | n/a | def printit(self): |
---|
6 | n/a | print(self.hi_there["command"]) |
---|
7 | n/a | |
---|
8 | n/a | def createWidgets(self): |
---|
9 | n/a | # a hello button |
---|
10 | n/a | self.QUIT = Button(self, text='QUIT', foreground='red', |
---|
11 | n/a | command=self.quit) |
---|
12 | n/a | self.QUIT.pack(side=LEFT, fill=BOTH) |
---|
13 | n/a | |
---|
14 | n/a | self.hi_there = Button(self, text='Hello', |
---|
15 | n/a | command=self.printit) |
---|
16 | n/a | self.hi_there.pack(side=LEFT) |
---|
17 | n/a | |
---|
18 | n/a | # note how Packer defaults to side=TOP |
---|
19 | n/a | |
---|
20 | n/a | self.guy2 = Button(self, text='button 2') |
---|
21 | n/a | self.guy2.pack() |
---|
22 | n/a | |
---|
23 | n/a | self.guy3 = Button(self, text='button 3') |
---|
24 | n/a | self.guy3.pack() |
---|
25 | n/a | |
---|
26 | n/a | def __init__(self, master=None): |
---|
27 | n/a | Frame.__init__(self, master) |
---|
28 | n/a | Pack.config(self) |
---|
29 | n/a | self.createWidgets() |
---|
30 | n/a | |
---|
31 | n/a | test = Test() |
---|
32 | n/a | test.mainloop() |
---|